f81243d8ead1b0a7b54e310a4a8ae46a3ce89b0d
[project/luci.git] /
1 "require ui";
2 "require rpc";
3 "require form";
4 "require baseclass";
5 "require adblock-fast.status as adb";
6
7 var pkg = adb.pkg;
8
9 return baseclass.extend({
10 title: _("AdBlock-Fast"),
11
12 load: function () {
13 return Promise.all([adb.getInitStatus(pkg.Name)]);
14 },
15
16 render: function (data) {
17 var reply = {
18 status: (data[0] && data[0][pkg.Name]) || {
19 enabled: false,
20 status: null,
21 running: null,
22 version: null,
23 errors: [],
24 warnings: [],
25 force_dns_active: null,
26 force_dns_ports: [],
27 entries: null,
28 dns: null,
29 outputFile: null,
30 outputCache: null,
31 outputGzip: null,
32 outputFileExists: null,
33 outputCacheExists: null,
34 outputGzipExists: null,
35 leds: [],
36 },
37 };
38 var statusTable = {
39 statusNoInstall: _("%s is not installed or not found").format(pkg.Name),
40 statusStopped: _("Stopped"),
41 statusStarting: _("Starting"),
42 statusProcessing: _("Processing lists"),
43 statusRestarting: _("Restarting"),
44 statusForceReloading: _("Force Reloading"),
45 statusDownloading: _("Downloading lists"),
46 statusError: _("Error"),
47 statusWarning: _("Warning"),
48 statusFail: _("Fail"),
49 statusSuccess: _("Active"),
50 };
51
52 var cacheText;
53 if (reply.status.outputCacheExists) {
54 cacheText = _("Cache file");
55 } else if (reply.status.outputGzipExists) {
56 cacheText = _("Compressed cache");
57 }
58 var forceDnsText = "";
59 if (reply.status.force_dns_active) {
60 reply.status.force_dns_ports.forEach((element) => {
61 forceDnsText += element + " ";
62 });
63 } else {
64 forceDnsText = "-";
65 }
66
67 var table = E(
68 "table",
69 { class: "table", id: "adblock-fast_status_table" },
70 [
71 E("tr", { class: "tr table-titles" }, [
72 E("th", { class: "th" }, _("Status")),
73 E("th", { class: "th" }, _("Version")),
74 E("th", { class: "th" }, _("DNS Service")),
75 E("th", { class: "th" }, _("Blocked Domains")),
76 E("th", { class: "th" }, _("Cache")),
77 E("th", { class: "th" }, _("Force DNS Ports")),
78 ]),
79 E("tr", { class: "tr" }, [
80 E(
81 "td",
82 { class: "td" },
83 statusTable[reply.status.status] || _("Unknown")
84 ),
85 E("td", { class: "td" }, reply.status.version || _("-")),
86 E("td", { class: "td" }, reply.status.dns || _("-")),
87 E("td", { class: "td" }, reply.status.entries || _("-")),
88 E("td", { class: "td" }, cacheText || _("-")),
89 E("td", { class: "td" }, forceDnsText || _("-")),
90 ]),
91 ]
92 );
93
94 return table;
95 },
96 });